const { declare } = require("@babel/helper-plugin-utils");

const anyCheckPlugin = declare((api, options, dirname) => {
  api.assertVersion(7);
  return {
    pre(file) {
      file.set("count", 0)
    },
    visitor: {
      TSAnyKeyword(path, state) {
        state.file.set("count", state.file.get("count") + 1)
      }
    },
    post(file) {
      console.info(`当前文件any的个数为：${file.get("count")}`)
    }
  }
})

module.exports = anyCheckPlugin;